// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2024 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.7
package sys

import (
	"context"
	"hotgo/addons/hgexample/api/admin/epbanner"
	"hotgo/addons/hgexample/model/input/sysin"
	"hotgo/addons/hgexample/service"
)

var (
	EpBanner = cEpBanner{}
)

type cEpBanner struct{}

// List 查看轮播图列表
func (c *cEpBanner) List(ctx context.Context, req *epbanner.ListReq) (res *epbanner.ListRes, err error) {
	list, totalCount, err := service.SysEpBanner().List(ctx, &req.EpBannerListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.EpBannerListModel{}
	}

	res = new(epbanner.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Export 导出轮播图列表
func (c *cEpBanner) Export(ctx context.Context, req *epbanner.ExportReq) (res *epbanner.ExportRes, err error) {
	err = service.SysEpBanner().Export(ctx, &req.EpBannerListInp)
	return
}

// Edit 更新轮播图
func (c *cEpBanner) Edit(ctx context.Context, req *epbanner.EditReq) (res *epbanner.EditRes, err error) {
	err = service.SysEpBanner().Edit(ctx, &req.EpBannerEditInp)
	return
}

// MaxSort 获取轮播图最大排序
func (c *cEpBanner) MaxSort(ctx context.Context, req *epbanner.MaxSortReq) (res *epbanner.MaxSortRes, err error) {
	data, err := service.SysEpBanner().MaxSort(ctx, &req.EpBannerMaxSortInp)
	if err != nil {
		return
	}

	res = new(epbanner.MaxSortRes)
	res.EpBannerMaxSortModel = data
	return
}

// View 获取指定轮播图信息
func (c *cEpBanner) View(ctx context.Context, req *epbanner.ViewReq) (res *epbanner.ViewRes, err error) {
	data, err := service.SysEpBanner().View(ctx, &req.EpBannerViewInp)
	if err != nil {
		return
	}

	res = new(epbanner.ViewRes)
	res.EpBannerViewModel = data
	return
}

// Delete 删除轮播图
func (c *cEpBanner) Delete(ctx context.Context, req *epbanner.DeleteReq) (res *epbanner.DeleteRes, err error) {
	err = service.SysEpBanner().Delete(ctx, &req.EpBannerDeleteInp)
	return
}

// Switch 更新轮播图开关状态
func (c *cEpBanner) Switch(ctx context.Context, req *epbanner.SwitchReq) (res *epbanner.SwitchRes, err error) {
	err = service.SysEpBanner().Switch(ctx, &req.EpBannerSwitchInp)
	return
}